<%--
  Created by IntelliJ IDEA.
  User: ZTencent
  Date: 2023/1/12
  Time: 11:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="${pageContext.request.contextPath}/statics/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/style.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome.min.css" />
    <link rel="stylesheet" href="Widget/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <link href="Widget/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <!--[if IE 7]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome-ie7.min.css" />
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="${pageContext.request.contextPath}/statics/js/jquery-1.9.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/typeahead-bs2.min.js"></script>
    <!-- page specific plugin scripts -->
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/H-ui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/H-ui.admin.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/layer/layer.js" type="text/javascript" ></script>
    <script src="${pageContext.request.contextPath}/statics/assets/laydate/laydate.js" type="text/javascript"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/Widget/zTree/js/jquery.ztree.all-3.5.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/js/lrtk.js" type="text/javascript" ></script>
    <title>产品列表</title>
</head>
<body>
<div class=" page-content clearfix">
    <div id="products_style">
        <div class="border clearfix">
       <span class="l_f">
        <a href="${pageContext.request.contextPath}/manager/category/add" title="添加分类" class="btn btn-warning Order_form"><i class="icon-plus"></i>添加分类</a>
        <a href="javascript:ovid()" class="btn btn-danger"><i class="icon-trash"></i>批量删除</a>
           <a href="javascript:ajaxheader()" class="btn btn-danger"><i class="icon-trash"></i>请求头</a>
           <a href="javascript:ajaxbody()" class="btn btn-danger"><i class="icon-trash"></i>请求体</a>
       </span>
        </div>
        <div class="table_menu_list clearfix" id="testIframe" style="width:100%">
            <table class="table table-striped table-bordered table-hover" id="sample-table" >
                <thead>
                <tr>
                    <th width="25px"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
                    <th width="80px">类名编号</th>
                    <th width="250px">类别名称</th>
                    <th width="100px">类别图标</th>
                    <th width="200px">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="mc" items="${mcList}">
                <tr>
                    <td width="25px"><label><input type="checkbox" name="inputdel" class="ace" value="${mc.mcId}" ><span class="lbl"></span></label></td>
                    <td width="80px">${mc.mcId}</td>
                    <td width="250px"><u style="cursor:pointer" class="text-primary" onclick="">${mc.mcName}</u></td>
                    <td width="100px"><img src="${pageContext.request.contextPath}/statics/upload/category/${mc.mcIcon}" height="50"/></td>
                    <td class="td-manage">
                        <a onClick="member_stop(this,'10001')"  href="javascript:;" title="停用"  class="btn btn-xs btn-success"><i class="icon-ok bigger-120"></i></a>
                        <a title="编辑"  href="${pageContext.request.contextPath}/manager/category/update?id=${mc.mcId}"  class="btn btn-xs btn-info" ><i class="icon-edit bigger-120"></i></a>
                        <a title="删除" href="javascript:;"  onclick="member_del(this,${mc.mcId})" class="btn btn-xs btn-warning" ><i class="icon-trash  bigger-120"></i></a>
                    </td>
                </tr>
                </c:forEach>


                </tbody>
            </table>
        </div>
    </div>
</div>
</div>
<script>
    function member_del(target,id) {
        var isdel=confirm("确定要删除吗?");
        if(isdel){
            $.getJSON("${pageContext.request.contextPath}/manager/category/del",{"id":id},function (e) {
                if(e.code==200){
                    $(target).parent().parent().remove();
                }else {
                    alert(e.message);
                }
            })
        }
    }

    function ovid() {
        var list=$(".ace[name='inputdel']:checked");
        var params=new Array();
        for(var i=0; i<list.length;i++){
            params[i]=list[i].value;
        }

        $.getJSON("${pageContext.request.contextPath}/manager/category/delbyids",{"ids":params},function (e) {
            if(e.code==200){
                $(target).parent().parent().remove();
            }else {
                alert(e.message);
            }
        })

    }
    
    function ajaxheader() {

        $.ajax({
            url:"${pageContext.request.contextPath}/manager/category/textheader",
            type:"get",
            headers:{"token":"abc123~.~"},
            dataType:"json",
            success:function (e) {
                alert(e.message);
            }
        })
    }
    
    function ajaxbody() {
        var data='{"mcId":"1","mcName":"张三","mcIcon":"123.jpg"}';
        var jsonstr=JSON.stringify(data);
        var parse = JSON.parse(data);
        alert(parse.mcId);

        $.ajax({
            url:"${pageContext.request.contextPath}/manager/category/textbody",
            type:"post",
            contentType:"application/json",
            dataType:"json",
            data:data,
            success:function (e) {
                alert(e.message);
            }
        })
    }
</script>
</body>
</html>

